<template>
	<view class="u-page">
		<view class="header">
		
		</view>
		
		<view class="content" >
			<view class="projecttitle">{{title}}</view>
			<view class="projectUser">
				<image src="../../../static/icon/user.png" mode=""></image>
				<text>法人代表</text>
				<text class="name">{{data.frName}}</text>
			</view>
			<view class="projectId">
				<view class="ID">统一社会代码</view>
				<view class="CarId">{{data.creditCode}}</view>
			</view>
			<view class="projectAddress">
				<view class="ID">地址</view>
				<view class="CarId">{{data.address}}</view>
			</view>
			<view class="projectFile" v-if="level ==1">
				<view>注册资金(单位:万元)：{{data.regCap}}</view>
				<view>登记机关：{{data.regOrg}}</view>
				<view>开业日期：{{data.esDate}}</view>
				<view>经营期限至：{{data.openTo}}</view>
				<view>企业(机构)类型：{{data.enterpriseType}}</view>
				<view>经营状态：{{data.enterpriseStatus}}</view>
				<view>经营(业务)范围：{{data.operateScope}}</view>
			</view>
			<view class="projectFile" v-else>
				<view>暂无权限查看其他信息</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pid:'',
				title:'',
				type:1,
				strings: '',
				data:{},
				userData:{},
				level:'0'
			}
			
		},
		onLoad(option) {
			console.log('1--',option)
			this.pid=option.id
			this.title=option.title
			
			
			let user = uni.getStorageSync('userData');
			this.userData = user;
			this.project(option.id)
		},
		methods: {
			async project(pid){
				const project = await this.GQL({
					"operationName": "allSlProjectBusinesses",
					"query": "query allSlProjectBusinesses($filter: SlProjectBusinessFilter) { allSlProjectBusinesses(filter:$filter) { nodes { address creditCode enterpriseName enterpriseStatus enterpriseType esDate frName openFrom openTo operateScopeAndForm operateScope regCap pid regCapCur regNo regOrg } } }",
					"variables": {"filter": {"pid": {"equalTo": pid}}}
				})
				
				//获取用户是否投资或充值
				const userData = await this.GQL({
					"operationName": "allSlUserProjectvips",
					"query": "query allSlUserProjectvips($filter: SlUserProjectvipFilter) { allSlUserProjectvips(filter:$filter) { nodes { vid uid pid level } } }",
					"variables": {"filter": {"uid": {"equalTo": this.userData.uid}}}
				})
							
				if(userData.data.allSlUserProjectvips.nodes !=''){
					this.level = '1'
				}else{
					this.level = '0'
				}
				if(project.data.allSlProjectBusinesses.nodes != ''){
					this.data = project.data.allSlProjectBusinesses.nodes[0]
				}else{
					this.getBusiness()
				}
			},
			getBusiness(){
				let that = this
				uni.request({
					url:that.HttpServe+"/Api/business",
					method:"POST",
					data:{
						pid:that.pid
					},
					success(res) {
						// console.log('res',res)
						if(res.data.code == 200){
							let list1 = res.data
							that.data = list1.data
						}else{
							uni.showToast({ title: '获取信息失败', icon: 'error', duration: 3000 });
							uni.navigateBack({
								delta: 1
							})
						}
						
					}
				})
			},
			goback(){
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="scss">
	.u-page{
		background-color: #FBFCFE;
	}
	 .header{
	 	width: 100%;
	 	height: 260px;
	 	/* color: #FFFFFF; */
		background: linear-gradient(#C7171E, #f0f2f5); /* 标准的语法 */
	 	
	 }
	 .content{
		 position: relative;
		 margin: 30rpx;
		 padding: 30rpx;
		 background-color: #FFFFFF;
		 min-height: 500px;
		 border-radius: 10px;
		 top: -260px;
		 .projecttitle{
			 font-size: 32rpx;
			 color: #161E3E;
			 font-weight: 500;
			 // padding: 10px;
		 }
		 .projectTag{
			 margin: 5px 15px 0px 15px;
			 .tag{
				 margin-left: 5px;
			 }
		 }
		 .projectcontent{
			 margin: 15px;
			 
		 }
		 
		 .projectUser{
			 margin: 20rpx 0;
			 color: #161E3E;
			 font-size: 30rpx;
			 line-height: 64rpx;
			 image{
				 width: 26rpx;
				 height:26rpx;
				 padding-right: 5px;
				 vertical-align: middle;
				 line-height: 26rpx;
			 }
			 .name{
				 color: #767B8D;
				 margin-left: 10px;
				 line-height: 26rpx;
				 font-size: 30rpx;
			 }
			
		 }
		 .CarId{
			 padding-top: 20rpx;
			 padding-bottom: 28rpx;
			 font-size: 15px;
			 color: #007AFE;
		 }
		 .ID{
			 font-size: 15px;
			 color: #838898;
		 }
		 .projectId{
			 margin: 20px 0;
			 border-bottom: 1px solid #D8D8D8;
		 }
		 .projectAddress{
			  margin: 20px 0;
		 }
		 .projectFile{
			  margin: 10px 0;
			  font-size: 28rpx;
			  font-family: PingFangSC-Regular, PingFang SC;
			  font-weight: 400;
			  color: #767B8D;
			  line-height: 18px;
		 }
	 }

</style>
